package com.ruoyi.weixincp.config;

import me.chanjar.weixin.cp.api.WxCpDepartmentService;
import me.chanjar.weixin.cp.api.WxCpMessageService;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.api.WxCpUserService;
import me.chanjar.weixin.cp.api.impl.WxCpDepartmentServiceImpl;
import me.chanjar.weixin.cp.api.impl.WxCpMessageServiceImpl;
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
import me.chanjar.weixin.cp.api.impl.WxCpUserServiceImpl;
import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 企业微信动默认配置
 */
@Configuration
public class WxCpConfiguration {
    private WxCpService wxCpService;
    private WxCpUserService wxCpUserService;
    private WxCpDepartmentService wxCpDepartmentService;
    private WxCpMessageService wxCpMessageService;

    @Bean
    public Boolean InitWxCpService() {
        WxCpDefaultConfigImpl configStorage=new  WxCpDefaultConfigImpl();
//        configStorage.setCorpId(weChatProperties.getCorpId());
//        configStorage.setAgentId(weChatProperties.getAgentId());
//        configStorage.setCorpSecret(weChatProperties.getSecret());
//        configStorage.setToken(weChatProperties.getToken());
//        configStorage.setAesKey(weChatProperties.getEncodingAesKey());

        // 掌微科技
        //        appId:  ww7aa18beb43ccacc0
        //        AgentId: 1000002
        //        Secret: lkCj2dH76GOdtFBp1vixAVZZxJkUlaw9TAnT_xDL650
         wxCpService=new WxCpServiceImpl();
        configStorage.setCorpId("ww7aa18beb43ccacc0");
        configStorage.setCorpSecret("lkCj2dH76GOdtFBp1vixAVZZxJkUlaw9TAnT_xDL650");
        configStorage.setAgentId(1000002);
        wxCpService.setWxCpConfigStorage(configStorage);
        wxCpUserService=new WxCpUserServiceImpl(wxCpService);
        wxCpDepartmentService=new WxCpDepartmentServiceImpl(wxCpService);
        wxCpMessageService=new WxCpMessageServiceImpl(wxCpService);
        return true;
    }

    public WxCpService getWxCpService() {
        return wxCpService;
    }

    public WxCpUserService getWxCpUserService() {
        return wxCpUserService;
    }

    public WxCpDepartmentService getWxCpDepartmentService() {
        return wxCpDepartmentService;
    }

    public WxCpMessageService getWxCpMessageService() {
        return wxCpMessageService;
    }
}

